<html>
<head><meta charset="utf-8"><title>Is there a way to parse fully-qualified syntax from a tool? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html">Is there a way to parse fully-qualified syntax from a tool?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211076490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211076490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211076490">(Sep 24 2020 at 00:04)</a>:</h4>
<p>Rustdoc wants to parse things like <code>A::&lt;B::Assoc as Trait&gt;&gt;::C</code> and we found it was a little tricky to do by hand. Is there an easy way to use <code>rustc_parse</code> for this?</p>



<a name="211076625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211076625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211076625">(Sep 24 2020 at 00:07)</a>:</h4>
<p>it looks like clippy already does something like this: <a href="https://github.com/rust-lang/rust/blob/master/src/tools/clippy/clippy_lints/src/write.rs#L374">https://github.com/rust-lang/rust/blob/master/src/tools/clippy/clippy_lints/src/write.rs#L374</a></p>



<a name="211076627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211076627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211076627">(Sep 24 2020 at 00:07)</a>:</h4>
<p>now I just need to get a TokenStream from somewhere <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="211076961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211076961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211076961">(Sep 24 2020 at 00:13)</a>:</h4>
<p>ayy here we go <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/fn.parse_stream_from_source_str.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/fn.parse_stream_from_source_str.html</a></p>



<a name="211077269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211077269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211077269">(Sep 24 2020 at 00:18)</a>:</h4>
<p>how do I get the filename from a <code>Span</code>?</p>



<a name="211077303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211077303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211077303">(Sep 24 2020 at 00:18)</a>:</h4>
<p>or <code>tcx</code>, that would work too, but I think it's not enough info because there are many files in a crate</p>



<a name="211077339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211077339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211077339">(Sep 24 2020 at 00:19)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/config/enum.Input.html#method.source_name">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/config/enum.Input.html#method.source_name</a> looks relevant, but not sure what an Input is</p>



<a name="211077428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211077428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211077428">(Sep 24 2020 at 00:20)</a>:</h4>
<p>ahhh</p>



<a name="211077484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211077484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211077484">(Sep 24 2020 at 00:22)</a>:</h4>
<p>looks like it comes from <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Compiler.html#method.input">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Compiler.html#method.input</a></p>



<a name="211077529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211077529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211077529">(Sep 24 2020 at 00:22)</a>:</h4>
<p>that looks like it's for the root file still</p>



<a name="211077750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211077750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211077750">(Sep 24 2020 at 00:26)</a>:</h4>
<p>well, or I could just make a name up lol <a href="https://github.com/rust-lang/rust/blob/master/src/librustdoc/passes/check_code_block_syntax.rs#L39">https://github.com/rust-lang/rust/blob/master/src/librustdoc/passes/check_code_block_syntax.rs#L39</a></p>



<a name="211078190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211078190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211078190">(Sep 24 2020 at 00:35)</a>:</h4>
<p>next question: how do I parse a qpath?</p>



<a name="211078315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211078315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211078315">(Sep 24 2020 at 00:37)</a>:</h4>
<p>hmm, maybe I could try <code>parse_expr</code> then <code>parse_ty</code> one after another?</p>



<a name="211078562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211078562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211078562">(Sep 24 2020 at 00:42)</a>:</h4>
<p>ok I think I'm going to give up on this</p>



<a name="211078613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211078613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211078613">(Sep 24 2020 at 00:42)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> before I rewrite qpath parsing from scratch in rustdoc do you have suggestions for how to do this?</p>



<a name="211078885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211078885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211078885">(Sep 24 2020 at 00:47)</a>:</h4>
<p>my progress so far: <a href="https://github.com/rust-lang/rust/pull/76934#discussion_r493975935">https://github.com/rust-lang/rust/pull/76934#discussion_r493975935</a></p>



<a name="211079380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211079380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211079380">(Sep 24 2020 at 00:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> do you know who I could ask about this?</p>



<a name="211079411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211079411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211079411">(Sep 24 2020 at 00:55)</a>:</h4>
<p>uh I guess maybe <span class="user-mention" data-user-id="119031">@Esteban Küber</span> or <span class="user-mention" data-user-id="133169">@matklad</span> might know</p>



<a name="211083635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211083635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211083635">(Sep 24 2020 at 02:20)</a>:</h4>
<p>Solution: make <code>parse_qpath</code> public? <span aria-label="stuck out tongue" class="emoji emoji-1f61b" role="img" title="stuck out tongue">:stuck_out_tongue:</span></p>



<a name="211083653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211083653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211083653">(Sep 24 2020 at 02:21)</a>:</h4>
<p><span class="user-mention" data-user-id="307537">@Camelid</span> it should be named 'finish_qpath', it assumes you've already seen an angle bracket</p>



<a name="211102754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211102754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211102754">(Sep 24 2020 at 08:36)</a>:</h4>
<blockquote>
<p><code>A::&lt;B::Assoc as Trait&gt;&gt;::C</code></p>
</blockquote>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> this is not valid syntax tho?</p>
<p>Did you mean <code>A::&lt;X, Y&gt;::B</code> (path with arguments) or <code>&lt;Type as Trait&gt;::C</code> (fully qualified syntax)?</p>



<a name="211102790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211102790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211102790">(Sep 24 2020 at 08:36)</a>:</h4>
<p>If the former, I think that should match the <code>$path</code> macro fragment specifier, and that is already public</p>



<a name="211102849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211102849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211102849">(Sep 24 2020 at 08:37)</a>:</h4>
<p>If the latter, I would be wary about XY problem -- you probably won't be able to do anything useful with fully qualified path without bringing in the trait machinery as well?</p>



<a name="211124384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211124384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211124384">(Sep 24 2020 at 12:35)</a>:</h4>
<p>I meant both - sorry for the bad syntax.</p>
<blockquote>
<p>If the latter, I would be wary about XY problem -- you probably won't be able to do anything useful with fully qualified path without bringing in the trait machinery as well?</p>
</blockquote>
<p>Rustdoc already uses the trait machinery: <a href="https://github.com/rust-lang/rust/blob/master/src/librustdoc/passes/collect_intra_doc_links.rs#L598">https://github.com/rust-lang/rust/blob/master/src/librustdoc/passes/collect_intra_doc_links.rs#L598</a></p>
<p>For context, there are two things I want to do:</p>
<ul>
<li>treat <code>HashMap&lt;Key, Value&gt;::new</code> as <code>HashMap::new</code> (rustdoc doesn't care about generic arguments): <a href="https://github.com/rust-lang/rust/issues/62834">https://github.com/rust-lang/rust/issues/62834</a></li>
<li>disambiguate <code>&lt;Type as Trait&gt;::C</code> from the inherent impl <code>Type::C</code>: <a href="https://github.com/rust-lang/rust/issues/74563">https://github.com/rust-lang/rust/issues/74563</a></li>
</ul>



<a name="211124481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211124481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211124481">(Sep 24 2020 at 12:36)</a>:</h4>
<p>a better example would be <code>A::&lt;module::B as module::Trait&gt;::D</code>, 90% sure that's valid syntax</p>



<a name="211165973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211165973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211165973">(Sep 24 2020 at 17:45)</a>:</h4>
<p>I think I got a basic parser that can handle these paths working. I'll push it up soon <span class="user-mention" data-user-id="232545">@Joshua Nelson</span></p>



<a name="211166084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211166084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211166084">(Sep 24 2020 at 17:45)</a>:</h4>
<p>I'm still not super comfortable duplicating the parsing in two places :/</p>



<a name="211167010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211167010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211167010">(Sep 24 2020 at 17:52)</a>:</h4>
<p>I pushed it up! It only needs to understand path separators and angle brackets so it's not too complicated.</p>



<a name="211925153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211925153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211925153">(Oct 01 2020 at 15:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F/near/211124481">said</a>:</p>
<blockquote>
<p>a better example would be <code>A::&lt;module::B as module::Trait&gt;::D</code>, 90% sure that's valid syntax</p>
</blockquote>
<p>you can just test it - it's not :P</p>



<a name="211925241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211925241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211925241">(Oct 01 2020 at 15:11)</a>:</h4>
<p><code>&lt;$ty as $path&gt;::</code> is a valid path <em>prefix</em></p>



<a name="211925557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211925557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211925557">(Oct 01 2020 at 15:12)</a>:</h4>
<p>IOW, the <code>as Trait</code> can be used if <em>and only if</em> the path starts with <code>&lt;</code></p>



<a name="211925576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211925576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211925576">(Oct 01 2020 at 15:12)</a>:</h4>
<p>this is why I want use rustc's parsing instead of rewriting it</p>



<a name="211955963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Is%20there%20a%20way%20to%20parse%20fully-qualified%20syntax%20from%20a%20tool%3F/near/211955963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Is.20there.20a.20way.20to.20parse.20fully-qualified.20syntax.20from.20a.20tool.3F.html#211955963">(Oct 01 2020 at 18:46)</a>:</h4>
<p>Once we support FQS, it might make sense to use rustc's parser, but for now it pretty much ignores everything in angle brackets <span aria-label="stuck out tongue" class="emoji emoji-1f61b" role="img" title="stuck out tongue">:stuck_out_tongue:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>